#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
int isPalindrome(int n)
{
	char c[100];
	int cnt = 0, num = 0;
	int x = n;
	for (int i = 0;x > 0; i++)
	{
		c[i] = x % 10 + '0';
		x /= 10;
		cnt++;
	}
	for (int j = 0; j < cnt; j++)
	{
		num += (c[j] - '0') * (int)pow(10, cnt - j - 1);
	}
	return num == n ? 1 : 0;
}
int main()
{
	int n, cnt = 0;
	int flag = 0;
	scanf("%d", &n);
	for (int i = 1000; i <= n; i++)
	{
		if (isPalindrome(i) == 1 && flag == 0)
		{
			printf("%d", i);
			flag = 1;
		}
		else if (isPalindrome(i) == 1 && flag == 1)
		{
			printf(" %d", i);
		}
	}
	return 0;
}